package com.example.mysqltry.service.impl;

import com.example.mysqltry.api.vo.NewBeeMallIndexCarouselVO;
import com.example.mysqltry.dao.MallCarouselMapper;
import com.example.mysqltry.entity.MallCarousel;
import com.example.mysqltry.service.NewBeeMallCarouselService;
import com.example.mysqltry.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Service
public class NewBeeMallCarouselServiceImpl implements NewBeeMallCarouselService {
    @Autowired
    private MallCarouselMapper mallCarouselMapper;
    @Override
    public  List<NewBeeMallIndexCarouselVO> getCarouselsForIndex(int number)
    {
        List<NewBeeMallIndexCarouselVO> newBeeMallIndexCarouselVOS=new ArrayList<>(number);

        List<MallCarousel> mallCarousels=mallCarouselMapper.findByNum(number);
        if(!CollectionUtils.isEmpty(mallCarousels))
        {
            newBeeMallIndexCarouselVOS= BeanUtil.copyList(mallCarousels,NewBeeMallIndexCarouselVO.class
            );
        }
        return   newBeeMallIndexCarouselVOS;

    }
}
